/*
 * js工具函数
 */

//js类继承

//垃圾IE
if (!Array.indexOf) {
	Array.prototype.indexOf = function(obj) {
        for (var i = 0, len = this.length; i < len; i++) {
            if (compare(this[i], obj)) return i;
        }
        return -1;
     };
}
function compare(obj1, obj2) {
    if (obj1 == null || obj2 == null) return (obj1 === obj2);
    return (obj1 == obj2 && obj1.constructor.toString() == obj2.constructor);
}
function extend(subClass,superClass){
	    var F = function(){};
	    F.prototype = superClass.prototype;
	    subClass.prototype = new F();
	    subClass.prototype.constructor = subClass;
	    subClass.superclass = superClass.prototype; //加多了个属性指向父类本身以便调用父类函数
	    if(superClass.prototype.constructor == Object.prototype.constructor){
	        superClass.prototype.constructor = superClass;
	    }
}
/**
 * 功能：数组去重复处理
 * 案例：var arr =['c','n','d','a','t','a','c','o','m']; console.info(arr.distinct());
 */
Array.prototype.distinct = function(){
    var self = this;
    var _a = this.concat().sort();
    _a.sort(function(a,b){
        if(a == b){
            var n = self.indexOf(a);
            self.splice(n,1);
        }
    });
    return self;
};
Date.prototype.addDay=function(){
   var n=1;
   if(arguments.length>0){
      n=arguments[0];
   }
   this.setTime(this.getTime()+n*24*3600*1000);
};
Date.prototype.reduceDay=function(){
   var n=1;
   if(arguments.length>0){
      n=arguments[0];
   }
   this.setTime(this.getTime()-n*24*3600*1000);
};
Date.prototype.addMonth=function(){
  var year=getAddClickDate(this).toDate();
  this.setFullYear(year.getFullYear(), year.getMonth(),year.getDate());
};
Date.prototype.reduceMonth=function(){
	var year=getReduceClickDate(this).toDate();
	this.setFullYear(year.getFullYear(),year.getMonth(),year.getDate());
};

/**
 * 返回日起字符串，格式如“2011-11-02”
 */
Date.prototype.toDateString = function() {
	var y = this.getFullYear();
	var m = this.getMonth()+1;
	m = m < 10 ? '0' + m : m;
	var d = this.getDate();
	d = d < 10 ? '0' + d : d;
	return y+'-'+m+'-'+d;
};
/**
 * 返回时间字符串，格式如“2011-11-02 01:02:03”
 */
Date.prototype.toTimeString = function() {
	var y = this.getFullYear();
	var m = this.getMonth()+1;
	m = m < 10 ? '0' + m : m;
	var d = this.getDate();
	d = d < 10 ? '0' + d : d;
	var h = this.getHours();
	h = h < 10 ? '0' + h : h;
	var min = this.getMinutes();
	min = min < 10 ? '0' + min : min;
	var s = this.getSeconds();
	s = s < 10 ? '0' + s : s;
	return y+'-'+m+'-'+d+' '+h+':'+min+':'+s;
};

//获取相加的月份日期   
function getAddClickDate(date){   
   var daysInMonth = new Array([0],[31],[28],[31],[30],[31],[30],[31],[31],[30],[31],[30],[31]);
   var strYear = date.getFullYear();     
   var strDay = date.getDate();     
   var strMonth = date.getMonth()+1;   
   if(strYear%4 == 0 && strYear%100 != 0){   
      daysInMonth[2] = 29;   
   }   
   if(strMonth +1 == 13){   
	   
      strYear += 1;   
      strMonth = 1;  
      
   }else{   
      strMonth += 1;   
   }   
   strDay = daysInMonth[strMonth] >= strDay ? strDay : daysInMonth[strMonth];   
//   if(strMonth<10)     
//   {     
//      strMonth=";0";+strMonth;     
//   }   
//   if(strDay<10)     
//   {     
//      strDay=";0";+strDay;     
//   }   
   datastr = strYear+"-"+strMonth+"-"+strDay;   
   return datastr;   
}

//获取相减的月份日期  
function getReduceClickDate(date){   
   var daysInMonth = new Array([0],[31],[28],[31],[30],[31],[30],[31],[31],[30],[31],[30],[31]);
   var strYear = date.getFullYear();     
   var strDay = date.getDate();     
   var strMonth = date.getMonth()+1;   
   if(strYear%4 == 0 && strYear%100 != 0){   
      daysInMonth[2] = 29;   
   }   
   if(strMonth - 1 == 0){   
	   
      strYear -= 1;   
      strMonth = 12;  
      
   }else{   
      strMonth -= 1;   
   }   
   strDay = daysInMonth[strMonth] >= strDay ? strDay : daysInMonth[strMonth];   
//   if(strMonth<10)     
//   {     
//      strMonth=";0";+strMonth;     
//   }   
//   if(strDay<10)     
//   {     
//      strDay=";0";+strDay;     
//   }   
   datastr = strYear+"-"+strMonth+"-"+strDay;   
   return datastr;   
}
Date.prototype.getFullMonth=function(){
   return this.getMonth()+1;
};
Date.prototype.getCurrentMonthLastDay=function(){
   var tempdate=new Date;//帮助类
	   tempdate.setFullYear(this.getFullYear(),this.getMonth()+1,1);
	   tempdate.setTime(tempdate.getTime()-24*3600*1000);
	    return Number(tempdate.getDate());
};
Date.prototype.getNextMonthLastDay=function(){
      var tempdate=new Date;//帮助类
	  tempdate.setFullYear(this.getFullYear(),this.getMonth()+2,1);
	  tempdate.setTime(tempdate.getTime()-24*3600*1000);
	  return Number(tempdate.getDate());
};
Date.prototype.getPrevMonthLastDay=function(){
    var tempdate=new Date;//帮助类
	  tempdate.setFullYear(this.getFullYear(),this.getMonth(),1);
	  tempdate.setTime(tempdate.getTime()-24*3600*1000);
	  return Number(tempdate.getDate());
};
Date.prototype.getFirstDayWeekd=function(){
    var tempdate=new Date();//帮助类
	tempdate.setFullYear(this.getFullYear(),this.getMonth(),1);
	var week=tempdate.getDay();
	return Number(week);
};
Date.prototype.getWeekCount=function(){
  var temp=(this.getFirstDayWeekd()+this.getCurrentMonthLastDay())%7;
	  if(temp==0){
		  return Math.floor((this.getFirstDayWeekd()+this.getCurrentMonthLastDay())/7);
	  }else{
		  return Math.floor((this.getFirstDayWeekd()+this.getCurrentMonthLastDay())/7)+1;
	  }
};
Date.prototype.cloneDate=function(){
	var y=this.getFullYear();
	var m=this.getMonth();
	var d=this.getDate();
	var h=this.getHours();
	var mm=this.getMinutes();
	var s=this.getSeconds();
	
	return new Date(y,m,d,h,mm,s);
};
Date.prototype.Format = function(format){
    var o = {  
         "M+" : this.getMonth()+1, //month  
         "d+" : this.getDate(),    //day  
         "H+" : this.getHours(),   //hour  
         "m+" : this.getMinutes(), //minute  
         "s+" : this.getSeconds(), //second  
         "q+" : Math.floor((this.getMonth()+3)/3), //quarter  
         "S" : this.getMilliseconds() //millisecond  
      };  
      if(/(y+)/.test(format)) 
        format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));  
      for(var k in o)
        if(new RegExp("("+ k +")").test(format))  
        format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));  
      return format;  
 };
function trim(str){  //删除左右两端的空格  
	var ren = ""; 
	if(typeof(str)!="undefined")
		ren = str.replace(/(^\s*)|(\s*$)/g, "");
 	return   ren;  
} 
String.prototype.toDate=function(p){
	if(!this)return "";
	var pfix=p||"-";
	array=this.split(" ");
	
	if(array.length<=1){
		var date1=array[0].split(pfix);
		if(date1.length>0){
			return new   Date(date1[0],Number(date1[1])-1,date1[2]);
		}
		return "";
	}
	var time=array[1].split(':');
	var date=array[0].split('-');
	return new   Date(date[0],Number(date[1])-1,date[2],time[0],time[1],time[2]);
};
function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz";
	var string_length = 16;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
//全部替换
String.prototype.replaceAll  = function(s1,s2){   
	return this.replace(new RegExp(s1,"gm"),s2);   
};
//匹配189邮箱
function isEmailCheck(emailStr){
    if (emailStr != "") {
   	    //var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
        var reg = /^([a-zA-Z0-9_-])+@(189)+((\.cn))$/;
        flag = reg.test(emailStr);
        if (!flag) {
            return false;
        }else{
        	return true;
        }
    }
}
//匹配邮箱
function isEmail(emailStr){
    if (emailStr != "") {
    	var reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
   	    //var reg = /^([a-zA-Z0-9_-\.])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
        flag = reg.test(emailStr);
        if (!flag) {
            return false;
        }else{
        	return true;
        }
    }
}
//匹配189手机
function isPhone189(phoneStr){
    if (phoneStr != "") {
   	    var reg = /^(133|153|180|189)+([0-9]{8})$/;
        flag = reg.test(phoneStr);
        if (!flag) {
            return false;
        }else{
        	return true;
        }
    }	
}

function isMobile(mobileStr){
    if (mobileStr != "") {
   	    var reg = /^0*(13|14|15|18)\d{9}$/;
        flag = reg.test(mobileStr);
        if (!flag) {
            return false;
        }else{
        	return true;
        }
    }		
}
function isTel(telStr){
    if (telStr != "") {
   	    var reg = /^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/;
        flag = reg.test(telStr);
        if (!flag) {
            return false;
        }else{
        	return true;
        }
    }	
}
//判断内容的字数，中文2个字节，英文1个字节
function stringLength(str){
    var totalCount = 0; 
    for (var i=0; i<str.length; i++) { 
        var c = str.charCodeAt(i); 
        if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) { 
             totalCount++; 
         }else {     
             totalCount+=2; 
         } 
     }
    // alert(totalCount);
    return totalCount;
}
//转到固定长度的十六进制字符串，不够则补0
function zero_fill_hex(num, digits) {
	var s = num.toString(16);
	while (s.length < digits)
	s = "0" + s;
	return s;
} 
function rgb2hex(rgb) {
	if (rgb.charAt(0) == '#')
	return rgb;
	var length=rgb.length;
	var sub=rgb.substring(4,length-1);
	var ds=sub.split(',');
	var decimal = Number(ds[0]) * 65536 + Number(ds[1]) * 256 + Number(ds[2]);
	return "#" + zero_fill_hex(decimal, 6);
} 
function better_time(strDateStart,strDateEnd){
	   var strSeparator = "-"; //日期分隔符
	   var strDateArrayStart;
	   var strDateArrayEnd;
	   var intDay;
	   strDateArrayStart = strDateStart.split(strSeparator);
	   strDateArrayEnd = strDateEnd.split(strSeparator);
	   var strDateS = new Date(strDateArrayStart[0] + "/" + strDateArrayStart[1] + "/" + strDateArrayStart[2]);
	   var strDateE = new Date(strDateArrayEnd[0] + "/" + strDateArrayEnd[1] + "/" + strDateArrayEnd[2]);
	   intDay = (strDateE-strDateS)/(1000*3600*24);
	   return intDay;
	}

function Stringbuilder(){
this.__string__ = new Array();
}
Stringbuilder.prototype.append = function(str){
this.__string__.push(str);
};
Stringbuilder.prototype.toString = function(){
return this.__string__.join("");
};

AjaxloadData=function(url,param,success,failure){
	
	$.ajax({
		 type:'post',
		 url:baseURL+url,
		 dataType:'json',
		 data:param,
		 success:function(json){
		      if(success)
		       success.call(this,json);
	     },
	     error:function(XMLHttpRequest, textStatus, errorThrown){
	    	var resp=XMLHttpRequest.responseText;
			if("417"==XMLHttpRequest.status){
				var json=JSON.parse(resp); 				
				alert(json.error);
			}else{
				//if(showTip){
				//	cdcnj.tooltip(resp);
				//}
			}
			if(failure){
				failure.call(this);
			}
	     }
	    });
};
var loadtext=function(url,param,success,failure){
	
	$.ajax({
		 type:'post',
		 url:BASEURL+url,
		 dataType:'text',
		 data:param,
		 success:function(text){
		      if(success)
		       success.call(this,text);
	     },
	     error:function(XMLHttpRequest, textStatus, errorThrown){
	    	var resp=XMLHttpRequest.responseText;
			if("417"==XMLHttpRequest.status){
				var json=JSON.parse(resp); 				
				alert(json.error);
			}else{
				//if(showTip){
				//	cdcnj.tooltip(resp);
				//}
			}
			if(failure){
				failure.call(this);
			}
	     }
	    });
};
function getFullDate(start){
	week=getWeek(start);
	var fulldataAndWeek=start.getFullYear()+'-'+start.getFullMonth()+'-'+start.getDate()+''+'('+week+')';
	return fulldataAndWeek;
	
}

function getWeek(start){
	var week=start.getDay();
	if(week==1){
		week='星期一';
	}else if(week==2){
		week='星期二';
	}else if(week==3){
		week='星期三';
	}else if(week==4){
		week='星期四';
	}else if(week==5){
		week='星期五';
	}else if(week==6){
		week='星期六';
	}else if(week==0){
		week='星期日';
	}
	return week;
}
function getWeek1(week){
	if(week==1){
		week='星期一';
	}else if(week==2){
		week='星期二';
	}else if(week==3){
		week='星期三';
	}else if(week==4){
		week='星期四';
	}else if(week==5){
		week='星期五';
	}else if(week==6){
		week='星期六';
	}else if(week==0){
		week='星期日';
	}
	return week;
}
function showdatepicker(option){
	var obj=option.textobj.call(this);
	var iobj=option.imgobj.call(this);
	iobj.bind('click',function(){
		obj.focus();
	});
	var defaulto={ 
			dateFormat: 'yy-mm-dd',  
	        clearText:'清除',
	        closeText:'关闭', 
	        prevText:'前一月', 
	        nextText:'后一月', 
	        currentText:' ', 
	        changeYear:true,
	        //changeMonth:true,
	        //showMonthAfterYear:true,
	        monthNames:['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
	        monthNamesShort:['1','2','3','4','5','6','7','8','9','10','11','12'],
	        dayNamesMin : [ "日", "一", "二", "三", "四", "五", "六" ]};
	var option;
	if(option.option){
		option=$.extend(defaulto,option.option);
	}else{
		option=defaulto;
	}
	obj.datepicker(option);
	$('#ui-datepicker-div').css('z-index',10001);
	$('#ui-datepicker-div').hide();
}
//renderTo afterSelect type afterCreate beforeCreate
function showSelectdatepicker(option){
	var renderTo=option.renderTo;
	var dateStr=option.dateStr;
	var dateArr =dateStr.split(",");
	var type=option.type;
	if(option.beforeCreate){
		option.beforeCreate.call(this,parseFloat(dateArr[0]),parseFloat(dateArr[1]),parseFloat(dateArr[2]));
	}
	var maxYear=cdcnj.sysDate.getFullYear();
	//如果没有合法日期 将使用当前日期
	if(typeof(dateStr)=="undefined"||trim(dateStr)==""||trim(dateStr)==null){
		$("#idBirthdayContactYear").val("");
		$("#idBirthdayContactMonth").val("");
		$("#idBirthdayContactDay").val("");		
	}else{		
		renderTo.empty();
		if(type=="LC"){
			renderTo.append("<select name='year' height=20></select> <select name='month' ></select> <select name='day'></select> ");	
		}else{
			renderTo.append("<select name='year' height=20></select>年<select name='month'></select>月<select name='day'></select>日");	
		}
		var SelYear=renderTo.find('select[name="year"]'), SelMonth=renderTo.find('select[name="month"]'), SelDay=renderTo.find('select[name="day"]');
		var ds = new DateSelector(type,SelYear,SelMonth,SelDay, {
			Year:parseFloat(dateArr[0]),
			Month:parseFloat(dateArr[1]),
			Day:parseFloat(dateArr[2]),
			MinYear: 1900,
			MaxYear: 2031
		},true);
		//ds.onChange();	
		renderTo.find('select').bind('change',function(){
			if(option.afterSelect){
				var y=renderTo.find('select[name="year"]').val(), m=renderTo.find('select[name="month"]').val(), d=renderTo.find('select[name="day"]').val();
				y=y||1800;
				if(y!=1800){
					if(SelMonth[0].options[0].value==""){
						$(SelMonth[0].options[0]).remove();
					}
					if(SelDay[0].options[0].value==""){
						$(SelDay[0].options[0]).remove();
					}
			    }else{
			    	if(option.monthIsNull){
						if(SelMonth[0].options[0].value==""){
							$(SelMonth[0].options[0]).remove();
						}
						
					}else{
						var months=SelMonth[0].options;
						var hasblank=false;
						for(var i=0;i<months.length;i++){
							if(months[0].value==''){
								hasblank=true;
								break;
							}
						}
						if(!hasblank){
							
							$(SelMonth).prepend("<option value=''></option>");
						}
					}
					if(option.dayIsNull){
						if(SelDay[0].options[0].value==""){
							$(SelDay[0].options[0]).remove();
						}
						
					}
			    }
				y=renderTo.find('select[name="year"]').val(), m=renderTo.find('select[name="month"]').val(), d=renderTo.find('select[name="day"]').val();
				y=y||1800;
				option.afterSelect.call(this,y,m,d);
			}
		});
		if(option.afterCreate){
			option.afterCreate.call(this,parseFloat(dateArr[0]),parseFloat(dateArr[1]),parseFloat(dateArr[2]));
		}
		SelYear[0].options[0].value="1800";
		
		if(parseFloat(dateArr[0])!=1800){
			if(SelMonth[0].options[0].value==""){
				$(SelMonth[0].options[0]).remove();
			}
			if(SelDay[0].options[0].value==""){
				$(SelDay[0].options[0]).remove();
			}
	    }else{
	    	if(option.monthIsNull){
				$(SelMonth[0].options[0]).remove();
			}
			if(option.dayIsNull){
				$(SelDay[0].options[0]).remove();
			}
	    }
		var allNull=option.allNull;
		if(allNull==true){
			$(SelYear).val('');
			$(SelMonth).val('');
			$(SelDay).val('');
		}
		
	}
}
function isIE(){
	 if (!window.ActiveXObject){
	       return false;
	  }else{
		  return true;
	  }
}
function IeVesion() {
	var Sys = {};
	var ua = navigator.userAgent.toLowerCase();
	var s;
	(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
	(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
	(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
	(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
	(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
	var ieversion;
	if (Sys.ie){
	ieversion = parseInt(Sys.ie);
	     return ieversion;

	} else if (Sys.firefox) {
	ieversion = Sys.firefox;
	//setIsTextReadOnly(true);
	} else if (Sys.chrome) {
	ieversion = Sys.chrome;
	} else if (Sys.opera) {
	ieversion = Sys.opera;
	}  else if (Sys.safari) {
	ieversion = Sys.safari;
	}
} 

function isOpera(){
	var Sys = {};
	var ua = navigator.userAgent.toLowerCase();
	var s;
	(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
	(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
	(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
	(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
	(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
	if(Sys.opera){
		return true;
	}else{
		return false;
	}
	
}
function isIE8(){
	if(isIE()&&IeVesion()==8){
		return true;
	}else{
		return false;
	}
}
function isIE9(){
	if(isIE()&&IeVesion()==9){
		return true;
	}else{
		return false;
	}
}
function isIE6(){
	if(isIE()&&IeVesion()==6){
		return true;
	}else{
		return false;
	}
}

function isIE7(){
	if(isIE()&&IeVesion()==7){
		return true;
	}else{
		return false;
	}
}
//是否是IE7和6
function isIE6and7(){
	if(isIE()&&IeVesion()<8){
		return true;
	}else{
		return false;
	}
}
//是否为手机用户
function isPhoneAccount(){
	
	if(accountType==2){
		return true;
	}else{
		return false;
	}
}
//是否有signature属性
function isSignature(){
	if(cdcnj.initData.userConfig.signature){
	   return cdcnj.initData.userConfig.signature;
	}else{
	   return cdcnj.initData.user.userName;
	}
}
/**
 * 不换行js函数
 * @return
 */
function noBrString(str,limitNum,pfix){
	var chineseChar=2;//一个汉字相当于几个英文字符
	var newString="";
	var length=0;
	for(var i=0;i<str.length;i++){
		var c=str.charAt(i);
		if(isChineseChar(c)){
			length=length+2;
		}else{
			length=length+1;
		}
		if(length<=limitNum){
			newString+=c;
		}
	}
	if(length<=limitNum){
		return newString;
	}else{
		return newString+"...";
	}
}
function isChineseChar(str){   
	  
	var badChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";   
	badChar += "abcdefghijklmnopqrstuvwxyz";   
	badChar += "0123456789";   
	badChar += " "+"　";//半角与全角空格   
	badChar += "`~!@#$%^&()-_=+]\\|:;\"\'<,>?/";//不包含*或.的英文符号  
	  
   if(""==str){   
	return false;   
   }   
   for(var i=0;i<str.length;i++){   
	var c = str.charAt(i);//字符串str中的字符   
	if(badChar.indexOf(c) > -1){   
	  return false;   
	 }   
   }   
   return true;  
}

// string startWith
String.prototype.startWith = function(s){
	if(s==null||s==""||this.length==0||s.length>this.length)
		return false;
	if(this.substr(0,s.length)==s)
		return true;
	else
		return false;
	return true;
};

// string endWith
String.prototype.EndWith=function(s){
	if(s==null||s==""||this.length==0||s.length>this.length)
		return false;
	if(this.substring(this.length-s.length)==s)
		return true;
	else
		return false;
	return true;
};

/**
 * 功能：字符串占位符替换
 * 案例：var str ='c{0}dat{1}{2}'; alert(str.format("n","a","com"));
 */
String.prototype.format = function() {
    if (arguments.length == 0) return this;
    for (var str = this, i = 0; i < arguments.length; i++) {
        str = str.replace(new RegExp('\\{' + (i) + '\\}', 'gm'), arguments[i]);
    }
    return str;
};

//根据指定日期获取该日期所在周的周一和周日时间
function weekFirstLast(date){
	var week = date.getDay();
	if(week==0)
		week = 7;
	var startDate = new Date(date.getFullYear(),date.getMonth(),date.getDate()-(week-1));
 	var endDate = new Date(date.getFullYear(),date.getMonth(),date.getDate()+7-week);
 	var result = {startDate:startDate,endDate:endDate};
 	return result;
}

//获取日期所在月份的第几周
function weekNo(date){
		var currentWeekLastDay = weekFirstLast(date).endDate;
		var firstWeek = new Date(date.getFullYear(),date.getMonth(),1);
		var firstWeekLastDate = weekFirstLast(firstWeek).endDate;
		var firstWeekLastDay = firstWeekLastDate;
		var num = (currentWeekLastDay - firstWeekLastDay)/1000/3600/24/7+1;
		switch(num){
			case 1:num = "一";break;
			case 2:num = "二";break;
			case 3:num = "三";break;
			case 4:num = "四";break;
			case 5:num = "五";break;
			case 6:num = "六";break;
			case 7:num = "七";break;
		}
		return {year:date.getFullYear(),month:date.getMonth()+1,weekNum:num};
		
	}
/**
 * (适用于当前要转化的Date已经为正确的日期)返回日期字符串，格式如“2011年11月02日 星期一”
 */
function toDateString2(date) {
	var y = date.getFullYear();
	var m = date.getMonth()+1;
	m = m < 10 ? '0' + m : m;
	var d = date.getDate();
	d = d < 10 ? '0' + d : d;
	var week = getWeek1(date.getDay());
	return y+'年'+m+'月'+d+'日'+week;
}
/**
 * (适用于当前要转化的Date已经为正确的日期)返回日期字符串，格式如“2011-11-02”
 */
function toDateString1(date) {
	var y = date.getFullYear();
	var m = date.getMonth()+1;
	m = m < 10 ? '0' + m : m;
	var d = date.getDate();
	d = d < 10 ? '0' + d : d;
	return y+'-'+m+'-'+d;
}

/**
 * 判断js对象是否为空
 * @param obj
 * @returns {Boolean}
 */
function isEmptyObject(obj){
    for(var n in obj){return false;} 
    return true; 
} 

function checkAmount(value){
	if(/^(-)?(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/i.test(value)){
		return true;
	}else{
		return false;
	}
}

/**
 * 处理子选择框是动态生成，需要手工设置onchange事件
 * @param o
 * @param name
 */
function check_all(o,name){
	$("input[name='"+name+"']").attr('checked',o.checked);
}
function check_child(o,id){
	var $obj = $('#'+id);
	var $items = $("input[name='"+o.name+"']");
	if($items.filter(":checked").length === $items.length){
		$obj.attr("checked",true);
	}else{
		$obj.removeAttr("checked");
	}
}